package utilities;

/**
 *  Utilities methods for converting between Units (distance, speed, Temperature, Presure)
 *
 * @author     Brad Mace
 * @version    $Revision: 1.4 $ $Date: 2004/02/23 05:54:09 $
 */
public class Converter {

    private Converter() {
    }


    //------------------------------------------------------------Distance
    /**
     *  Converts feet to meters.
     *
     * @param  feet  distance (feet)
     * @return       distance (meters)
     */
    public static double feetToMeters(double feet) {
        return feet * .3048;
    }

    /**
     *  Converts meters to feet.
     *
     * @param  meters  distance (meters)
     * @return         distance (feet)
     */
    public static double metersToFeet(double meters) {
        return meters / .3048;
    }

    /**
     *  Description of the Method
     *
     * @param  kilometers  Description of the Parameter
     * @return             Description of the Return Value
     */
    public static double kilometersToMiles(double kilometers) {
        return kilometers * .62;
    }

    /**
     *  Description of the Method
     *
     * @param  miles  Description of the Parameter
     * @return        Description of the Return Value
     */
    public static double milesToKilometers(double miles) {
        return miles * 1.6;
    }

    //--------------------------------------------------------------------Speed
    /**
     *  Description of the Method
     *
     * @param  knots  Description of the Parameter
     * @return        Description of the Return Value
     */
    public static double knotsToMetersPerSecond(double knots) {
        return knots * .514;
    }

    /**
     *  Description of the Method
     *
     * @param  knots  Description of the Parameter
     * @return        Description of the Return Value
     */
    public static double knotsToMilesPerHour(double knots) {
        return ((knots * 6076.1) / 5280);
    }

    /**
     *  Description of the Method
     *
     * @param  mps  Description of the Parameter
     * @return      Description of the Return Value
     */
    public static double mpsToMph(double mps) {
        mps *= 60 * 60;// meters per hour
        mps /= 1000;// kilometers per hour
        mps = kilometersToMiles(mps);// miles per hour
        return mps;
    }

    /**
     *  Description of the Method
     *
     * @param  mph  Description of the Parameter
     * @return      Description of the Return Value
     */
    public static double mphToMps(double mph) {
        mph /= 60 * 60;// miles per second
        mph = milesToKilometers(mph);// kilometers per second
        mph *= 1000;// meters per second
        return mph;
    }


    //--------------------------------------------------------------Temperature
    /**
     *  Description of the Method
     *
     * @param  degrees  Description of the Parameter
     * @return          Description of the Return Value
     */
    public static double celsiusToFahrenheit(double degrees) {
        return ((degrees * (9.0 / 5)) + 32);
    }

    /**
     *  Description of the Method
     *
     * @param  degrees  Description of the Parameter
     * @return          Description of the Return Value
     */
    public static double fahrenheitToCelsius(double degrees) {
        return ((5 / 9.0) * (degrees - 32));
    }


    //-------------------------------------------------------------------Pressure
    /**
     *  Description of the Method
     *
     * @param  millibars  Description of the Parameter
     * @return            Description of the Return Value
     */
    public static double millibarsToInches(double millibars) {
        return millibars / 33.8653;
    }

    /**
     *  Description of the Method
     *
     * @param  inches  Description of the Parameter
     * @return         Description of the Return Value
     */
    public static double inchesToMillibars(double inches) {
        return inches * 33.8653;
    }
    //}}}
}
